// pages/user_wallet/user_wallet.js

const $ = require('../../utils/utils');
const wallet = require("../../manager/walletManager");
const user = require("../../manager/userManager");
var app = getApp();
const config = require('../../config');
Page({

  /**
   * 页面的初始数据
   */
  data: {
      isHaveDeposit:true,
      cash:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
      let that = this
    
      let cash_amount = wx.getStorageSync("cash_amount")
      this.setData({
          cash: cash_amount
      })

      user.getCurrentUserInfo().then(data=>{
          let deposit_flag = wx.getStorageSync("deposit_flag")
          that.setData({
              isHaveDeposit: deposit_flag
          })
      }).catch(error=>{

      })


  },

  userRecord: function (e) {
      $.goto(config.page.userRecord)
  },

  toVipPage: function(){
      $.goto(config.page.vip)
  },

  toTopupDepositPage: function () {
      $.goto(config.page.walletDeposit)
  },

  toTopupCashPage: function () {
      $.goto(config.page.pay)
  },

  retureDeposit: function () {
      let that = this
      app.globalData.webview = {
          url: config.refundUrl + "?userid=" + wx.getStorageSync("userid") + "&usertoken=" + wx.getStorageSync("usertoken"),
          title: '退还押金'
      };
      $.goto(config.page.webview);
  }
})